import { http } from '@/utils/http';
import type { ApiResponse, VoteLeaderboard } from '@/types';

// 获取投票排行榜（兼容旧版本）
export const getVoteLeaderboard = (params?: { limit?: number }): Promise<ApiResponse<VoteLeaderboard[]>> => {
  return http.get('/client/votes/leaderboard', { params });
}

// 投票
export const voteForArtist = (artistId: number, activityId: number): Promise<ApiResponse<{
  success: boolean;
  message: string;
}>> => {
  return http.post('/client/votes', { artistId, activityId });
}

// 检查用户投票状态
export const getVoteStatus = (activityId: number): Promise<ApiResponse<{
  activityId: number;
  votes: any[];
  totalVotes: number;
}>> => {
  return http.get('/client/votes/status', { params: { activityId } });
}

// 获取用户投票历史
export const getVoteHistory = (params?: {
  page?: number;
  limit?: number;
}): Promise<ApiResponse<{
  votes: Vote[];
  total: number;
}>> => {
  return http.get('/client/votes/history', { params })
} 